
function gravity() {
    let canvas = document.getElementById("_canvas");
    let ctx = canvas.getContext("2d");
    let engine = new Engine(ctx);
    let layer = new Layer(ctx); 

    layer.create = function () {
        let walls = createWall(canvas, ctx, layer);
        let ball = new ArcObject(50);
        ball.x = 400;
        ball.y = 100;
        let gravity = 9.8;
        let speed = 0;
        let friction = 0;
        ball.update = function (delta) {
            let speedInc = delta * gravity;
            this.y += speed * delta + delta * speedInc / 2;
            speed = speed + speedInc;
        }
        ball.addCollisionEvent(walls[2], function (event) {
            ball.strokeStyle = 'red';
            speed = 0 - speed + friction;
        }, function (event) {
            ball.strokeStyle = 'black';
        });
        layer.addObject(ball);
    }
    engine.addLayer(layer);
    engine.run();
    return engine;
}